/*
 * $Id$
 */
package ua.org.energy.vkek.site;

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import javax.persistence.EntityManager;
import org.junit.After;
import org.junit.Before;
import ua.org.energy.vkek.site.server.EMF;


public class EMFTestBase {
    
    
    public final LocalServiceTestHelper helper =
            new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
    protected EntityManager em;
    
    @Before
    public void setUp() {
        helper.setUp();
        //em = EMF.getEMF().createEntityManager();
        em = EMF.getEM();
    }

    @After
    public void tearDown() {
        if (em != null) {
            if (em.isOpen()) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                em.close();
            }
        }
        helper.tearDown();
    }

}
